#include <stdio.h>
#include <sys/types.h>         
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, const char *argv[])
{
	int sockfd=socket(AF_INET,SOCK_STREAM,0);
	struct sockaddr_in serveraddr,clientaddr;
	socklen_t addrlen=sizeof(serveraddr);

	serveraddr.sin_family=AF_INET;
	serveraddr.sin_addr.s_addr=inet_addr(argv[1]);
	serveraddr.sin_port=htons(atoi(argv[2]));

	bind(sockfd,(struct sockaddr *)&serveraddr,addrlen);

	listen(sockfd,5);
	printf("waiting\n");
	int getfd=accept(sockfd,(struct sockaddr *)&clientaddr,&addrlen);
	printf("connect!\n");
	char sndbuf[128];

	while(1)
	{
		recv(getfd,sndbuf,128,0);
		printf("recv:%s\n",sndbuf);
		memset(sndbuf,0,128);

	}

	return 0;
}
